<template>
    <div>
        <el-skeleton :rows="8" :loading="loading" animated>
        <el-table :data="tableData" style="width: 100%;height: 330px;" max-height="350">
            <el-table-column prop="id" v-if="false" label="编号" align="center" />
            <el-table-column type="index" label="序号" align="center" width="80" />
            <el-table-column prop="name" label="职务/岗位" width="180" />
            <el-table-column label="操作">
                <template #default="scope">
                    <!-- Popconfirm气泡确认框 -->
                  
                        <el-button plain round size="mini" type="primary" @click="select(scope.row)">
                            请选择</el-button>
                  
                </template>
            </el-table-column>
        </el-table>
    </el-skeleton>
    </div>
</template>
<script lang="ts">
import { defineComponent,reactive,toRefs,onMounted } from 'vue'
import {GetZhiwuList} from '../../../api/user/user'

export default defineComponent({
    props: ["lv","ids","names"],
    // emits:["zhiwu"],
    setup(props,context) {
        const data = reactive({
            tableData:[],
            loading:true,
            page: 1,
            limit: 999,
        })
        const events ={
            //把选择的值传给父组件
            select(item:any){
                var obj={
                oid:props.ids,
                zid:item.id,
                zname:item.name,
                oname:props.names,
            }
            context.emit("zhiwu",obj)
            },
            datas(){
                GetZhiwuList({
                    page: data.page,
                    limit: data.limit,
                }).then((res:any)=>{
                    // console.log('ddadaadada',res)
                //     if (res.result == 0) {
                //     res.data.data.forEach((item:any)=>{
                //         if(item.lv>=props.lv){
                //             data.tableData.push(item)
                //         }
                //     })
                // }
                // data.loading=false;
                data.tableData = res.data.data
                data.loading = false
                })
            }
        }
        onMounted(() => {
            events.datas()

        })
        return{
            ...events,
            ...toRefs(data)
        }
    },
})
</script>
